using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WPCoco;
using WPCoco.Particles;
using Microsoft.Xna.Framework.Input.Touch;
using WPCoco.Controllers;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using WPCoco.Graphics;

namespace ParticlesDemo.Scenes
{
    public class PhoenixScene : DemoScene
    {
        public PhoenixScene()
        {
            Title = "Phoenix";

            IsRunningChange += new EventHandler(MainScene_IsRunningChange);

            ParticleSystem p = ParticleSystem.LoadFromFile("Phoenix");
            p.SourcePosition = Screen.Center;
            pnode = new ParticleSystemNode(p);
            AddNode(pnode);
        }

        void MainScene_IsRunningChange(object sender, EventArgs e)
        {
            if (IsRunning)
                ControllerManager.Shared.TouchScreen.Dragging += new EventHandler<CustomEventArgs<GestureSample>>(TouchScreen_Dragging);
            else 
                ControllerManager.Shared.TouchScreen.Dragging -= new EventHandler<CustomEventArgs<GestureSample>>(TouchScreen_Dragging);
        }

        ParticleSystemNode pnode;

        void TouchScreen_Dragging(object sender, CustomEventArgs<GestureSample> e)
        {
            pnode.System.SourcePosition = e.Value.Position;
        }
    }
}
